//
//  NSDate+Format.m
//  ITC_iOS
//
//  Created by Benz.L on 10/09/2018.
//  Copyright © 2018 Benz.L. All rights reserved.
//

#import "NSDate+Format.h"

NSDateFormatter *DateFormatter() {
    static NSDateFormatter *dateFormatter = nil;
    if (!dateFormatter) {
        dateFormatter = [[NSDateFormatter alloc] init];
        NSTimeZone *zone = [NSTimeZone timeZoneWithName:@"Asia/Shanghai"];
        [dateFormatter setTimeZone:zone];
//        [wdateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
//        [wdateFormatter setLocale:[NSLocale currentLocale]];
        [dateFormatter setTimeStyle:NSDateFormatterFullStyle];
    }
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    
    return dateFormatter;
};

@implementation NSDate(Format)

- (NSString *)dateWithFormat:(NSString *)format {
    NSDateFormatter *dateFormatter = DateFormatter();
    if (format.length) {
        [dateFormatter setDateFormat:format];
    }
    return [dateFormatter stringFromDate:self];
}

@end
